//2. 创建组件
//3. 定义路由
import about from "../components/about"
import home from "../components/home"
import news from "../components/news"
import message from "../components/message"
import user from "../components/user"
import userDetail from "../components/userDetail"
const routes = [
  {path:"/about",component:about,props:route=>({name:route.query.name})},
  {
    path:"/home",
    component:home,
    // 嵌套路由
    children:[
      {path:"news",component:news},
      {path:"message",component:message},
      {path:"",redirect:"news"},
    ]
  },
  {
    path:"/user",
    component:user,
    children:[
      {
          name:"user",
          path:":id",
          component:userDetail,
          // 布尔值 : 只能传递params
          // 对象   ：传递的值比较死
          // 函数   : 功能最强大
          props:(route)=>{
            return {
              id:route.params.id,
              name:route.query.name,
              age:route.query.age
            }
          }
      },
      {path:"",redirect:"1"}
    ]
  },
  {path:"/test/:id?",component:userDetail,props:true,name:"test"},
  {path:"/",redirect:"/about"}
]

export default routes

// {path:"/user/:id",component:user}
